#pragma once
#include <iostream>
#include <vector>
#include <functional>

using std::cout;
using std::endl;
void download()
{
    cout << "downloading..." << endl;
}

void write_log()
{
    cout << "write log..." << endl;
}

class task
{
public:
    static task& get_task()
    {
        return _task;
    }
    //下载任务
    void download()
    {
        cout << "downloading..." << endl;
    }
    //写日志
    void write_log()
    {
        cout << "write log..." << endl;
    }

    std::vector<std::function<void()>> _vtask;
private:
    //设置为单例模式
    task()
    {
        _vtask.push_back([this](){this->download();});
        _vtask.push_back([this](){this->write_log();});
    };
    ~task(){};
    task(const task& ) = delete;
    task& operator=(const task&) = delete;

    static task _task;//单例对象
};

task task::_task;

